package com.heaven.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.heaven.pojo.ItemCat;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ItemCatMapper extends BaseMapper<ItemCat> {
    @Select("select * from item_cat where parent_id=#{parentId}")
    List<ItemCat> findItemCatList(int parentId);

    @Update("update item_cat set status=#{status},updated=#{updated}" +
            "where id=#{id}")
    void updateStatus(ItemCat itemCat);

    @Insert("insert into item_cat value(null,#{parentId},#{name},#{status}," +
            "#{level},#{created},#{updated})")
    void saveItemCat(ItemCat itemCat);

    @Update("update item_cat set name=#{name},updated=#{updated} where id=#{id}")
    void updateItemCat(ItemCat itemCat);

    @Delete("delete from item_cat where id=#{id}")
    void deleteItemCat3(Integer id);
    @Delete("delete from item_cat where id=#{id} or parent_id=#{id}")
    void deleteItemCat2(Integer id);

    void deleteItemCat1(Integer id);
}
